package com.ram.service.impl;

import com.ram.mapper.AssetCategoryMapper;
import com.ram.pojo.AssetCategory;
import com.ram.service.AssetCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class AssetCategoryServiceImpl implements AssetCategoryService {
    @Autowired
    private AssetCategoryMapper categoryMapper;

    @Override
    public List<AssetCategory> list() {
        return categoryMapper.list();
    }

    @Override
    public AssetCategory getById(Integer id) {
        return categoryMapper.getById(id);
    }

    @Override
    public void add(AssetCategory category) {
        category.setCreateTime(LocalDateTime.now());
        category.setUpdateTime(LocalDateTime.now());
        categoryMapper.insert(category);
    }

    @Override
    public void update(AssetCategory category) {
        category.setUpdateTime(LocalDateTime.now());
        categoryMapper.update(category);
    }

    @Override
    public void deleteById(Integer id) {
        categoryMapper.deleteById(id);
    }
} 